<admintpl file="header" />
<?php if($return_val == 1){?>
<link rel="stylesheet" href="__PUBLIC__/css/simple_upload.css" type="text/css" />
<?php }?>
</head>
<body>
<?php
	if(isset($add_from) && $add_from == 1)
	{
		$add_from = 1;
	}else
	{
		$add_from = 0;
	}
?>
	<div class="wrap">
		<ul class="nav nav-tabs">
			<if condition="$add_from eq '0'">
				<li><a href="{:U('Admin/LiveFast/index')}">快直播列表</a></li>
				<li class="active"><a href="{:U('Admin/LiveFast/add')}">添加快直播</a></li>
			</if>
				<if condition="$add_from eq 1">
					<!--<li><a href="{:U('Admin/NewsManage/publish', array('news_id'=>$news_id, $id_type=>$id_val,'add_from'=>1))}">新闻详情</a></li>-->
					<li class="active"><a href="{:U('Admin/live/add',array($id_type=>$id_val,'add_from'=>1))}">直播详情</a></li>
					<!--<li><a href="{:U('Admin/live/manage', array( $id_type=>$id_val,'add_from'=>1))}">管理</a></li>-->
				</if>
			</ul>
			<?php if($return_val == 0){?>
				<iframe src='<?php echo C("cmshost");?>/live/add-live/<?php echo $admin_id; ?>?admin_name=<?php echo  $res_admin_name;?>' id="iframepage" name="iframepage" frameBorder="0" width="100%" height="90%" allowfullscreen="true"></iframe>
				<style>
					html, body, .wrap {
						height: 100%;
					}
					.wrap {
						box-sizing: border-box;
					}
				</style>
			<?php }else{ ?>
			<form method="post" id="form_submit" class="form-horizontal js-ajax-form" action="{:U('Admin/Live/add_post',array($id_type=>$id_val,'add_from'=>$add_from))}" >
					<div class="control-group">

						<label class="span1 control-label" style="width: 90px;color:red">*直播类型：</label>
						<div class="span4">
							<select style="width: 126px;margin-left: 4px;" id="liveType_id" name="liveType" onchange="is_showadmin(this.options[this.options.selectedIndex].value)">
								<foreach name="liveType" key="type_id"  item="vo">
									<option value="{$type_id}">{$vo}</option>
								</foreach>
							</select>
							<span id="check_fast_status"><input type="checkbox" id="fast_live_status" name="fast_live_status"  style="margin:0 0 4px 10px;" onchange="is_fast(this.value)"> <span style="color: blue;">快直播</span></span>
						</div>

						<label class="span1 control-label" style="width: 90px;">直播名称：</label>
						<div class="span4">
							<input type="text" name="name" >
						</div>

						<label class="span1 control-label" style="width: 90px;"><nobr>权重：</nobr></label>
						<div class="span3">
							<input type="text" name="weight" <?php if($add_from == 1){echo "value='70' readOnly='true'";}?>>
						</div>
					</div>
					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">开始时间：</label>
						<div class="span4">
							<input type="text" name="start_time" class="js-datetime"  value="" autocomplete="off">
						</div>
						<label class="span1 control-label" style="width: 90px;">封面图片：</label>
						<div class="span4 wrapper">
							  <div id="uploader-image">
								  <div id="fileList" class="uploader-list">
									  <div id="imageDiv" class="file-item thumbnail" style="width:150px;height: 150px;">
										  <img id="imagePreview" src="__PUBLIC__/images/furley_bg.png" style="width:150px;height: 140px;">
										  <div id="picker" class="info">选择图片&nbsp;&nbsp;&nbsp;&nbsp;</div>
										  <input style="display:none;" type="file" id="imageFile" name="imageFile" >
									  </div>
								  </div>
							  </div>
						</div>
						<div id="screen_div">
							<label class="span1 control-label" style="width: 90px;">画面方向：</label>
							<div class="span4">
								<select style="width: 126px;margin-left: 4px;" id="screen" name="screen" >
									<option value="0">横屏</option>
									<option value="1">竖屏</option>
								</select>
							</div>
						</div>
					</div>
					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">直播线路：</label>
						<div>
							<div class="angle_tpl_div" style="float:left;">
								<div class="span4">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>机位一：</nobr></label>
									<label class="span1 control-label" style="width: 35px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>名称</nobr></label>
									<input type="text" id="angle_name1" name="angle_name[]" style="width: 108px;margin-left: 4px;">
								</div>
								<label class="span1 control-label" style="width: 30px;">频道</label>
								<div class="span2">
									<select style="width: 126px;margin-left: 4px;" id="angle_channel_id1" onchange="angle_channel_change('angle_channel_id1');" name="angle_channel_id[]">
										<foreach name="channelList" item="vo">
											<option value="{$vo.channel_id}" id="angle_channel_id1-{$vo.channel_id}" data-device_type="{$vo.device_type}">{$vo.channel_name}</option>
										</foreach>
									</select>
								</div>
								<label class="span1 control-label" style="width: 50px;margin-left: 4px;"><nobr>推流业务员</nobr></label>
								<div class="span3">
									<input type="hidden" id="angle_operator_id_h_1" value="0" name="angle_operator_id[]"/>
									<select style="width: 108px;margin-left: 4px;" id="angle_operator_id1" name="angle_operator_id[]">
										<option>aaa</option>
									</select>
									<img src="__PUBLIC__/images/tv-expandable.gif" style="cursor:pointer;width:16px;" id="add_angle_tpl"/>
								</div>
							</div>
							<div class="angle_tpl_div" style="float:left;margin-left: 110px;margin-top: 5px;">
								<div class="span4">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>机位二：</nobr></label>
									<label class="span1 control-label" style="width: 35px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>名称</nobr></label>
									<input type="text" id="angle_name2" name="angle_name[]" style="width: 108px;margin-left: 4px;">
								</div>
								<label class="span1 control-label" style="width: 30px;">频道</label>
								<div class="span2">
									<select style="width: 126px;margin-left: 4px;" id="angle_channel_id2" onchange="angle_channel_change('angle_channel_id2');" name="angle_channel_id[]">
										<foreach name="channelList" item="vo">
											<option value="{$vo.channel_id}" id="angle_channel_id2-{$vo.channel_id}" data-device_type="{$vo.device_type}">{$vo.channel_name}</option>
										</foreach>
									</select>
								</div>
								<label class="span1 control-label" style="width: 50px;margin-left: 4px;"><nobr>推流业务员</nobr></label>
								<div class="span3">
									<input type="hidden" id="angle_operator_id_h_1" value="0" name="angle_operator_id[]"/>
									<select style="width: 108px;margin-left: 4px;" id="angle_operator_id2" name="angle_operator_id[]">
										<option>aaa</option>
									</select>
								</div>
							</div>
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;"><label>
						  <input type="checkbox" id="type" name="type" value="2" style="margin-bottom:4px;"> <span>赛事信息</span>
						   </label></label>
						<div style="float:left;">
							<div class="span4">
								<label class="span1 control-label" style="width: 60px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>红方选手</nobr></label>
								<select style="width: 208px;margin-left: 4px;" name="red_competitor_id">
									<foreach name="competitorList" item="vo">
										<option value="{$vo.competitor_id}">{$vo.real_name}</option>
									</foreach>
								</select>
							</div>
							<label class="span1 control-label" style="width: 30px;">URL</label>
							<div class="span3">
								<input type="text" name="red_news_url" style="width: 200px;margin-left: 4px;">
							</div>
						</div>
						<div style="float:left;margin-left: 0px;margin-top: 5px;">
							<div class="span4">
								<label class="span1 control-label" style="width: 60px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>蓝方选手</nobr></label>
								<select style="width: 208px;margin-left: 4px;" name="blue_competitor_id">
									<foreach name="competitorList" item="vo">
										<option value="{$vo.competitor_id}">{$vo.real_name}</option>
									</foreach>
								</select>
							</div>
							<label class="span1 control-label" style="width: 30px;">URL</label>
							<div class="span3">
								<input type="text" name="blue_news_url" style="width: 200px;margin-left: 4px;">
							</div>
						</div>
					</div>
					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">
						   <label>
							 <input type="checkbox" id="news_status" name="news_status" value="1" style="margin-bottom:4px;"> <span>相关新闻</span>
						   </label>
						</label>
						<div>
							<div class="news_tpl_div" style="float:left;">
								<div class="span4">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>URL</nobr></label>
									<input type="text" id="news_url1" name="news_url[]" style="width: 200px;margin-left: 4px;">
								</div>
								<label class="span1 control-label" style="width: 30px;">权重</label>
								<div class="span3">
									<input type="text" id="news_weight1" name="news_weight[]" value="70" style="width: 178px;margin-left: 4px;">
									<!-- <img src="__PUBLIC__/images/tv-expandable.gif" style="cursor:pointer;width:16px;" id="add_news_tpl"/> -->
								</div>
							</div>
							<div class="news_tpl_div" style="float:left;margin-left: 0px;margin-top: 5px;">
								<div class="span4">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>URL</nobr></label>
									<input type="text" id="news_url2" name="news_url[]" style="width: 200px;margin-left: 4px;">
								</div>
								<label class="span1 control-label" style="width: 30px;">权重</label>
								<div class="span2">
									<input type="text" id="news_weight2" name="news_weight[]" value="70" style="width: 178px;margin-left: 4px;">
								</div>
							</div>
							<div class="news_tpl_div" style="float:left;margin-left: 0px;margin-top: 5px;">
								<div class="span4">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>URL</nobr></label>
									<input type="text" id="news_url2" name="news_url[]" style="width: 200px;margin-left: 4px;">
								</div>
								<label class="span1 control-label" style="width: 30px;">权重</label>
								<div class="span2">
									<input type="text" id="news_weight2" name="news_weight[]" value="70" style="width: 178px;margin-left: 4px;">
								</div>
							</div>
							<div class="news_tpl_div" style="float:left;margin-left: 0px;margin-top: 5px;">
								<div class="span4">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>URL</nobr></label>
									<input type="text" id="news_url2" name="news_url[]" style="width: 200px;margin-left: 4px;">
								</div>
								<label class="span1 control-label" style="width: 30px;">权重</label>
								<div class="span2">
									<input type="text" id="news_weight2" name="news_weight[]" value="70" style="width: 178px;margin-left: 4px;">
								</div>
							</div>
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">未开始视频</label>
						<label class="span1 control-label" style="width: 80px;">是否VR</label>
						<div class="span2">
							<select class="select_2" name="is_vr1" id="is_vr1" style="width: 174px;">
								<option value="1">否</option>
								<option value="2">是</option>
							</select>
						</div>
						<label class="span1 control-label" style="width: 80px;margin-left:34px;">选择视频</label>
						<div class="span3">
							<input type="file" name="video1" />
						</div>
						<label class="span1 control-label" style="width: 90px;">腾讯云文件名</label>
						<div class="span3">
							<input type="text" name="qcloud_file_name1"  style="width: 200px;" value="">
						</div>
						<label class="span1 control-label" style="width: 90px;">腾讯云file_id</label>
						<div class="span3">
							<input type="text" name="file_id1"  style="width: 200px;" value="">
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">回放视频</label>
						<label class="span1 control-label" style="width: 80px;">是否VR</label>
						<div class="span2">
							<select class="select_2" name="is_vr2" id="is_vr2" style="width: 174px;">
								<option value="1">否</option>
								<option value="2">是</option>
							</select>
						</div>

						<label class="span1 control-label" style="width: 80px;margin-left:34px;">选择视频</label>
						<div class="span3">
							<input type="file" name="video2" />
						</div>
						<label class="span1 control-label" style="width: 90px;">腾讯云文件名</label>
						<div class="span3">
							<input type="text" name="qcloud_file_name2"  style="width: 200px;" value="">
						</div>
						<label class="span1 control-label" style="width: 90px;">腾讯云file_id</label>
						<div class="span3">
							<input type="text" name="file_id2"  style="width: 200px;" value="">
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;"><label>
						  <input type="checkbox" id="introduction_status" name="introduction_status" value="1" style="margin-bottom:4px;"> <span>直播介绍</span>
						   </label></label>
						<div>
							<div style="float:left;">
								<div class="span9">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>标题</nobr></label>
									<input type="text" name="title" style="width: 248px;margin-left: 4px;">
								</div>
							</div>
							<div style="float:left;margin-left: 0px;margin-top: 5px;">
								<div class="span9">
									<label class="span1 control-label" style="width: 50px;text-align:left:padding-right:2px;margin-left: 4px;"><nobr>详情</nobr></label>
									<textarea style="width: 498px; height: 70px;margin-left:4px;" name="introduction"></textarea>
								</div>
							</div>
						</div>
					</div>
					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">是否增加竞猜功能</label>
						<div class="span2">
							<select class="select_2" name="quiz_status" id="quiz_status" style="width: 174px;">
								<option value="0">否</option>
								<option value="1">是</option>
							</select>
						</div>
					</div>
					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">是否增加打赏功能</label>
						<div class="span2">
							<select class="select_2" name="prop_status" id="prop_status" style="width: 174px;">
								<option value="">请选择打赏</option>
								<option value="1" <if condition="$is_props eq 1">selected</if>>双人PK打赏</option>
								<option value="2" <if condition="$is_props eq 2">selected</if>>直播打赏</option>
								<option value="3" <if condition="$is_props eq 3">selected</if>>多人打赏</option>
								<option value="4" <if condition="$is_props eq 4">selected</if>>多人PK打赏</option>
							</select>
						</div>
					</div>
					<?php
						$no_start_view_ranage_from = '';
						$no_start_view_ranage_to = '';
						$loading_view_ranage_from = '';
						$loading_view_ranage_to = '';
						$end_view_ranage_from = '';
						$end_view_ranage_to = '';
						$no_start_view_ranage = isset($view_range_list[0]) ? $view_range_list[0] : array();
						$loading_view_ranage = isset($view_range_list[1]) ? $view_range_list[1] : array();
						$end_view_ranage = isset($view_range_list[2]) ? $view_range_list[2] : array();
						if($no_start_view_ranage){
								$no_start_view_ranage_arr = explode('-',$no_start_view_ranage);
								$no_start_view_ranage_from = isset($no_start_view_ranage_arr[0]) ? $no_start_view_ranage_arr[0] : '';
								$no_start_view_ranage_to = isset($no_start_view_ranage_arr[1]) ? $no_start_view_ranage_arr[1] : '';
						}
						if($loading_view_ranage){
								$loading_view_ranage_arr = explode('-',$loading_view_ranage);
								$loading_view_ranage_from = isset($loading_view_ranage_arr[0]) ? $loading_view_ranage_arr[0] : '';
								$loading_view_ranage_to = isset($loading_view_ranage_arr[1]) ? $loading_view_ranage_arr[1] : '';
						}
						if($end_view_ranage){
								$end_view_ranage_arr = explode('-',$end_view_ranage);
								$end_view_ranage_from = isset($end_view_ranage_arr[0]) ? $end_view_ranage_arr[0] : '';
								$end_view_ranage_to = isset($end_view_ranage_arr[1]) ? $end_view_ranage_arr[1] : '';
						}
					?>
					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">直播未开始浏览数随机设置</label>
						<div class="span2">
							<input type="text" name="no_start_view_ranage_from"  style="width: 120px;" value="{$no_start_view_ranage_from}">
						</div>
						<label class="span1 control-label" style="width: 0px;"> ~ </label>
						<div class="span2" style="padding-left:20px;">
							<input type="text" name="no_start_view_ranage_to"  style="width: 130px;" value="{$no_start_view_ranage_to}">
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">直播进行中浏览数随机设置</label>
						<div class="span2">
							<input type="text" name="loading_view_ranage_from"  style="width: 120px;" value="{$loading_view_ranage_from}">
						</div>
						<label class="span1 control-label" style="width: 0px;"> ~ </label>
						<div class="span2" style="padding-left:20px;">
							<input type="text" name="loading_view_ranage_to"  style="width: 130px;" value="{$loading_view_ranage_to}">
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">直播结束浏览数随机设置</label>
						<div class="span2">
							<input type="text" name="end_view_ranage_from"  style="width: 120px;" value="{$end_view_ranage_from}">
						</div>
						<label class="span1 control-label" style="width: 0px;"> ~ </label>
						<div class="span2" style="padding-left:20px;">
							<input type="text" name="end_view_ranage_to"  style="width: 130px;" value="{$end_view_ranage_to}">
						</div>
					</div>

					<div class="control-group">
						<label class="span1 control-label" style="width: 90px;">
						   <label>
							 <label class="span1 control-label" style="width: 100px;text-align:left:padding-right:2px;margin-left: 4px;color:red">*直播员属性(图文直播必填)：</label>
						   </label>
						</label>
						<div>
							<div class="news_tpl_div" style="float:left;">
								<div class="span4" style="width:600px">
									头像<img src="http://vrlive-10047449.image.myqcloud.com/lv1481274674584a7532dc9b1.png" style="width:54px;height: 54px;;margin-left:4px"><input type="file" id="avatar_file_id" name="avatar_file" style="width:150px;margin-left:8px" />
									<span  style="width: 50px;text-align:left;padding-right:2px;margin-left: 50px;">类别</span>
									<input type="text" id="live_man_cate_id" name="live_man_cate" style="width: 200px;margin-left: 4px;" value="{$live_man_cate}">
								</div>
								<label class="span1 control-label" style="width: 30px;">别名</label>
								<div class="span3">
									<input type="text" id="live_man_alias_id" name="live_man_alias" value="{$live_man_alias}" style="width: 178px;margin-left: 4px;">
								</div>

							</div>
						</div>
					</div>

					<div class="control-group" id="live_manages" style="border:1px solid #000; ">
						<div class="left"><span id="admin_type_name">直播推流业务员</span><input style="width: 950px;" name="live_admin_names" id="live_admin_names" type="text" value="" /></div>
						<div style="line-height: 30px; ">
							<foreach name="admin_infos" key="admin_key" item="admin_value">
								<input admin_name="{$admin_value['real_name']}" name="live_admin_res[]"  type="checkbox" value="{$admin_value['admin_id']}" />{$admin_value['real_name']}<span style="margin-right: 10px;"></span>
							</foreach>

							<input  name="live_admin_ids" id="live_admin_ids" type="hidden" value="" />
						</div>


					</div>

					<!--<div class="control-group" id="live_channel_manages" style="border:1px solid #000; ">-->
						<!--<div class="left">直播推流业务员</div>-->
						<!--<div style="line-height: 30px; ">-->
							<!--<foreach name="admin_infos" key="admin_key" item="admin_value">-->
								<!--<input admin_name="{$admin_value['username']}" name="live_channel_res[]"  type="checkbox" value="{$admin_value['admin_id']}" />{$admin_value['username']}<span style="margin-right: 10px;"></span>-->
							<!--</foreach>-->

						<!--</div>-->
					<!--</div>-->

					<div class="control-group">
						<label class="span2 control-label" style="width: 90px;">直播备忘：</label>
						<div class="span7">
							<textarea style="width: 556px; height: 70px;" name="remark"></textarea>
						</div>
					</div>

				<div class="form-actions" style="padding-left:260px;">
					<input type="hidden" name="words" value="">
					<button type="button" class="btn btn-primary js-ajax-submit" data-type="add">保存</button>
					&nbsp;&nbsp;<a class="btn" href="{:U('Admin/Live/index')}">{:L('BACK')}</a>
				</div>
			</form>
		<?php } ?>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
		<?php if($return_val == 0){?>
		<script src="__PUBLIC__/js/layer/layer.js"></script>
		<script type="text/javascript" src="__PUBLIC__/js/content_addtop.js"></script>
		<script type="text/javascript" >
			$(function(){
				document.getElementById('live_manages').style.display = 'none';
				document.getElementById('check_fast_status').style.display = 'none';
				document.getElementById('screen_div').style.display = 'none';
	//			document.getElementById('live_channel_manages').style.display = 'none';

	//			图文直播业务员
				$("[name='live_admin_res[]']").click(function(){
					var admin_id = $(this).val();
					var admin_name = $(this).attr('admin_name');
					var admin_hidden_ids = $('#live_admin_ids').val();
					var admin_values = $('#live_admin_names').val();

					if($("input[name='live_admin_res[]']:checked").length > 4){
						alert('指派业务员最多4个人');
						return false;
					}

					var ids_arr = admin_hidden_ids.split(",");
					var values_arr = admin_values.split(",");

					if(ids_arr.indexOf(admin_id) == '-1') {
						admin_hidden_ids+=admin_id+',';
						admin_values += admin_name + ',';
						$("#live_admin_names").val(admin_values);
						$("#live_admin_ids").val(admin_hidden_ids);
					}else{
						$.each(ids_arr,function(index,item){
							if(item==admin_id){
								ids_arr.splice(index,1);
								values_arr.splice(index,1);
							}
						})
						admin_hidden_ids = ids_arr.join(",");
						admin_values     = values_arr.join(",");
						$("#live_admin_names").val(admin_values);
						$("#live_admin_ids").val(admin_hidden_ids);
					}

				})

	//			直播推流业务员
				$("[name='live_channel_res[]'").click(function(){
					if($("input[name='live_channel_res[]']:checked").length > 1){
						alert('指派业务员只能 1 个人');
						return false;
					}
				})
			});
			function add_check(){
				var name = $("input[name='name']").val() ? $("input[name='name']").val() : '';
				var title = $("input[name='title']").val() ? $("input[name='title']").val() : '';
				var introduction = $("[name='introduction']").val() ? $("[name='introduction']").val() : '';
				var live_man_cate_id = $("#live_man_cate_id").val() ? $("#live_man_cate_id").val() : '';
				var live_man_alias_id = $("#live_man_alias_id").val() ? $("#live_man_alias_id").val() : '';
				var angle_name = $("[name='angle_name[]']");
				var angle_name_arr = [];
				for(i=0;i<angle_name.length;i++){
					angle_name_arr.push(angle_name[i].value);
				}
				var flag = false;
				$.ajax({
					type:"post",
					async:false,
					url:"{:U('Admin/Movement/filter_words')}",
					data:'name='+name+'&title='+title+'&introduction='+introduction+'&live_man_cate_id='+live_man_cate_id+'&live_man_alias_id='+live_man_alias_id+'&content='+angle_name_arr,
					dataType:"text",
					success:function(data){
						if(data){
							if(confirm('您编辑的内容涉及敏感词'+data+'是否继续操作')){
								flag= true;
							}else{
								flag= false;
							}
						}else{
							flag = true;
						}
					}
				});
				return flag;
			}
			function html5Reader(file, previewId){
				var file = file.files[0];
				var reader = new FileReader();
				reader.readAsDataURL(file);
				reader.onload = function(e){
					$('#'+previewId).attr('src', this.result);
				}
			}
			function image_change(fileId, previewId) {
				var pic = document.getElementById(previewId),
						file = document.getElementById(fileId);

				var ext = file.value.substring(file.value.lastIndexOf(".")+1).toLowerCase();

				// gif在IE浏览器暂时无法显示
				if(ext != 'png' && ext != 'jpg' && ext != 'jpeg'){
					alert("图片的格式必须为png或者jpg或者jpeg格式！");
					return;
				}
				var isIE = navigator.userAgent.match(/MSIE/)!= null,
						isIE6 = navigator.userAgent.match(/MSIE 6.0/)!= null;

				if(isIE) {
					file.select();
					var realLocalPath = document.selection.createRange().text;

					// IE6浏览器设置img的src为本地路径可以直接显示图片
					if (isIE6) {
						pic.src = realLocalPath;
					}else {
						// 非IE6版本的IE由于安全问题直接设置img的src无法显示本地图片，但是可以通过滤镜来实现
						pic.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\"" + realLocalPath + "\")";
						// 设置img的src为base64编码的透明图片 取消显示浏览器默认图片
						pic.src = '';
					}
				}else {
					html5Reader(file, previewId);
				}
			}

			$("#picker").click(function(){
				$("#imageFile").click();
			});

			$("#imageFile").change(function(){
				image_change('imageFile', 'imagePreview');
			});

			$("#add_angle_tpl").click(function(){
				$("#angle_tpl_div").after($("#angle_tpl_div").html());
				var obj = $("div[class=angle_tpl_div]:last");
				var h = '<div class="angle_tpl_div" style="float:left;margin-left: 110px;margin-top: 5px;">' + obj.html() + '</div>';
				var l = $("div[class=angle_tpl_div]").length;
				if(l >= 5){
					alert('最多只能添加5个机位！');
					return;
				}else if(l == 4) {
					h = h.replace('机位四', '机位五');
				}else if(l == 3) {
					h = h.replace('机位三', '机位四');
				}else if(l == 2) {
					h = h.replace('机位二', '机位三');
				}
				h = h.replace('angle_name' + l, 'angle_name' + (l + 1));
				h = h.replace(new RegExp("angle_channel_id" + l ,"gm"), 'angle_channel_id' + (l + 1));
				h = h.replace('angle_operator_id' + l, 'angle_operator_id' + (l + 1));
				obj.after(h);
				$('#angle_channel_id' + (l + 1)).change();

			});
			$("#add_news_tpl").click(function(){
				var obj = $("div[class=news_tpl_div]:last");
				var h = '<div class="news_tpl_div" style="float:left;margin-left: 110px;margin-top: 5px;">' + obj.html() + '</div>';
				var l = $("div[class=news_tpl_div]").length;
				//替换id
				h = h.replace('news_url' + l, 'news_url' + (l + 1));
				h = h.replace('news_weight' + l, 'news_weight' + (l + 1));
				obj.after(h);
			});

			function angle_channel_change(id){

				var id = $('#' + id).attr('id');
				var index = id.replace('angle_channel_id', '');
				var channel_id = $('#' + id).val();
				var device_type = $('#' + id + '-' + channel_id).attr('data-device_type');
				if(3 == device_type){
					$('#angle_operator_id_h_' + index).attr('disabled', true);
					$('#angle_operator_id' + index).attr('disabled', false);
					$.get("{:U('Admin/Live/get_channel_operators')}&channel_id=" + channel_id, function(r){
						if(r.data){
							var html = '';
							for(var item in r.data){
								html += '<option value="' + r.data[item].operator_id +'">' + r.data[item].real_name +'</option>'
							}
							$('#angle_operator_id' + index).html(html);
						}
					});
				}else{
					$('#angle_operator_id' + index).attr('disabled', true);
					$('#angle_operator_id_h_' + index).attr('disabled', false);
					$('#angle_operator_id' + index).html('<option value="0" selected></option>');
				}
			}

	//		function is_showadmin(is_admin) {
	//			document.getElementById('screen_div').style.display = 'none';
	//			if(is_admin > 2){
	//				document.getElementById('live_manages').style.display = '';
	//			}else{
	//				document.getElementById('live_manages').style.display = 'none';
	//			}
	//			if(is_admin == 1 || is_admin == 3 || is_admin == 4){
	//				document.getElementById('check_fast_status').style.display = '';
	//			}else{
	//				document.getElementById('check_fast_status').style.display = 'none';
	//			}
	//
	//			var fast_val = $("input[name='fast_live_status']:checked").val();
	//			if(is_admin == 1){
	//				$('#admin_type_name').html('直播推流业务员');
	//				if(fast_val == 'on'){
	//					document.getElementById('screen_div').style.display = '';
	//				}
	//			}
	//			if(is_admin == 3 || is_admin == 4){
	//				$("#admin_type_name").html('图文直播业务员');
	//			}
	////			if((is_admin == 1 || is_admin == 4) && fast_val == 'on'){
	////				document.getElementById('live_channel_manages').style.display = '';
	////			}else{
	////				document.getElementById('live_channel_manages').style.display = 'none';
	////			}
	//		}

			function is_fast(fast) {
				var fast_val = $("input[name='fast_live_status']:checked").val();
				if(fast_val == 'on'){
					var type_sel = $('#liveType_id option:selected').val();
					if(type_sel == 1){
						document.getElementById('screen_div').style.display = '';
					}
	//				if(type_sel == 1 || type_sel == 4){
	//					document.getElementById('live_channel_manages').style.display = '';
	//				}else{
	//					document.getElementById('live_channel_manages').style.display = 'none';
	//				}
				}else{
					document.getElementById('screen_div').style.display = 'none';
	//				document.getElementById('live_channel_manages').style.display = 'none';
				}
			}

			$('#angle_channel_id1').change();
			$('#angle_channel_id2').change();
		</script>
	<?php }?>
</body>
</html>